<?php
 session_start();
//include our login functions.
require('login_functions.php');
require('opendb.php');

 
//retrieve post data
$user = trim($_POST['user']);
$pass = trim($_POST['pass']);
$page = $_POST['currentPage'];
 
clear_login_state();
 
if (isset($user) && isset($pass)) 
{	 
	if (check_login_correct($user, $pass))
	{ 
		//set appropiate session vars
		login_user($user, $pass);
		
		if ($_SESSION['status'] == "Ban")
		{
			$_SESSION['statusMessage'] = "Sorry " . $_SESSION['user'] . ", but you are banned!";
			include("logout.php");
		}
	}
}

require('closedb.php');

if (empty($page))	// send to home page
	send_to_page("../home.php");
else	//redirect to last visited page
	send_to_page("../$page");

?>